class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2024-10-02",
      revision: "b86fb6e1b72853288cb7ffca25a83704c10cd391"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sequoia: "cb5b00f7a193c4a185139f4bc45c9def44729b858970afaf0f5e48763d4ee9d9"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:  "7a0f683b3cf9661ce275a63953e7ef54b9de11cfb7ad2a26856fcd4bfc13cb11"
    sha256 cellar: :any_skip_relocation, arm64_ventura: "7089289ee00daefa65f8eab8cc3de6707d6d8e4493ccd0720b693239a76b759d"
    sha256 cellar: :any_skip_relocation, sonoma:        "4a57587c072d87bad5796c8423db690f83e9138cd7e27761364d46b8f56dbf60"
    sha256 cellar: :any_skip_relocation, ventura:       "75c42cc541b036a64c586e55a82d73141b1030e1467f99d9e0c1fd4951db9a6f"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "8964b4c3459f8f212731b4cc08eb636396788e9f1fa3902413e0f40edeb731fd"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system bin/"searchsploit", "sendpage"
  end
end
